package com.unicom.office.templatefunc;

import com.unicom.office.dataitem.NumberDataItem;
import com.unicom.office.dataitem.StringDataItem;
import com.unicom.office.runtime.OfficeRuntime;
import com.unicom.office.type.NumberTypeItem;
import com.unicom.office.type.TypeItem;
import com.unicom.office.unit.OfficeUnit;

import java.util.List;

public class MultFunc extends TemplateFunc {
    public static final MultFunc INSTANCE = new MultFunc();

    private MultFunc(){}

    public Object run(List<Object> params, OfficeRuntime officeRuntime) {
        Double num = 1d;
        for (Object param : params) {
            NumberDataItem temp = (NumberDataItem) param;
            num *= temp.getDoubleValue();
        }
        return NumberDataItem.create(num);
    }

    public void runForMatch(OfficeUnit unit, List<Object> params, OfficeRuntime officeRuntime) {

    }

    public String getName() {
        return "mult";
    }

    public TypeItem getType() {
        return NumberTypeItem.INSTANCE;
    }
}
